<?php
    if(isset($_POST['submit'])){
        if (isset ($_FILES['new_image'])){
            $imagename = 'avatar.png';
            $source = $_FILES['new_image']['tmp_name'];
            $target = "./../template/img/".$imagename;
            move_uploaded_file($source, $target);
            $imagepath = $imagename;
            $save = "./../template/img/" . $imagepath; 
            $file = "./../template/img/" . $imagepath;
            echo '<script language=javascript>document.location.href="./../index.php"</script>';
        }
    }
?>